import Foundation

public extension String {
    subscript(i: Int) -> Character {
        let index = self.index(startIndex, offsetBy: i)
        return self[index]
    }
    
    subscript(range: Range<Int>) -> String {
        let lowerBoundIndex = self.index(self.startIndex, offsetBy: range.lowerBound)
        let upperBoundIndex = self.index(self.startIndex, offsetBy: range.upperBound)
        let rangeInStringIndex = lowerBoundIndex ..< upperBoundIndex
        let stringSlice = self[rangeInStringIndex]
        return String(stringSlice)
    }
}
